<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 做一个加法运算器 -->
        <input type="text" v-model="num1"> <span>+</span> <input type="text" v-model="num2"> <button>=</button>
        <span>{{ sum }}</span>

        <p>{{sum}}</p>
        <p>{{sum}}</p>
        <p>{{sum}}</p>
        <p>{{sum}}</p>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                num1: 0,
                num2: 0
            },
            // 计算属性
            computed: {

                sum() {
                    console.log('sum被调用了')
                    return parseInt(this.num1) + parseInt(this.num2)
                }
            }
        })
    </script>
</body>

</html>